summaryrefslogtreecommitdiff
path: root/src/pages/google_merchant/products/[page].js
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-05-25 09:02:56 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-05-25 09:02:56 +0700
commit53c8d78dc2a7d5f0a7fe0d562b0e685744d900f1 (patch)
treec20f558deb9b426310b9be1f5bc5067527852fe6 /src/pages/google_merchant/products/[page].js
parent8a9d61b5049b3eeca0dd40429b05dc7e60e26671 (diff)
Fixing google merchant xml
Diffstat (limited to 'src/pages/google_merchant/products/[page].js')
-rw-r--r--src/pages/google_merchant/products/[page].js15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js
index 7db826bb..aaa4dde4 100644
--- a/src/pages/google_merchant/products/[page].js
+++ b/src/pages/google_merchant/products/[page].js
@@ -24,14 +24,21 @@ export async function getServerSideProps({ res, query }) {
products.response.products.forEach((product) => {
const productUrl = createSlug('/shop/product/', product.name, product.id, true)
const productId = product.code != '' ? product.code : product.id
- const productDescription = product.description?.replace(/<[^>]*>/g, ' ') || ''
+ const regexHtmlTags = /(<([^>]+)>)/gi
+ product.description = product.description?.replace(regexHtmlTags, ' ').trim()
+ const defaultProductDescription =
+ 'Indoteknik.com menawarkan berbagai produk industri, konstruksi, dan teknik terpercaya. Temukan mesin industri, peralatan listrik, alat pengukur, dan banyak lagi. Pengalaman berbelanja mudah dengan deskripsi produk lengkap, spesifikasi teknis, dan gambar jelas. Pembayaran aman, pengiriman cepat ke seluruh Indonesia. Solusi lengkap untuk kebutuhan Kantor, Industri & Teknik Anda.'
+
+ if (!product.description) {
+ product.description = defaultProductDescription
+ }
const item = {
'g:id': { '#text': productId },
- 'g:title': { '#text': `<![CDATA[${toTitleCase(product.name)}]]>` },
- 'g:description': { '#text': `<![CDATA[${productDescription}]]>` },
+ 'g:title': { '#text': toTitleCase(product.name) },
+ 'g:description': { '#text': product.description },
'g:link': { '#text': productUrl },
- 'g:image': { '#text': product.image },
+ 'g:image_link': { '#text': product.image },
'g:condition': { '#text': 'new' },
'g:availability': { '#text': 'in_stock' },
'g:brand': { '#text': product.manufacture?.name || '' },